package io_nio;

import java.io.Serializable;

/**
 * Created by butterfly on 2018/6/28.
 */
public class SingletonPerson implements Serializable{
    private String name;
    private int age;
    private static SingletonPerson instance;

    private SingletonPerson(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public static SingletonPerson getInstance(){
        if (instance == null){
            instance = new SingletonPerson("测试单例",17);
        }
        return instance;
    }

    public Object readResolve(){
        return instance;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
